package com.maosong.photo.entity;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by 李涛 on 16/4/21.
 */
public class PhotoEntry implements Parcelable {

    private int bucketId;
    private int imageId;
    private long dateTaken;
    private String path;
    private boolean isChecked;

    public PhotoEntry() {

    }

    public PhotoEntry(int bucketId, int imageId, long dateTaken, String path) {
        this.bucketId = bucketId;
        this.imageId = imageId;
        this.dateTaken = dateTaken;
        this.path = path;
    }

    protected PhotoEntry(Parcel in) {
        bucketId = in.readInt();
        imageId = in.readInt();
        dateTaken = in.readLong();
        path = in.readString();
        isChecked = in.readByte() != 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(bucketId);
        dest.writeInt(imageId);
        dest.writeLong(dateTaken);
        dest.writeString(path);
        dest.writeByte((byte) (isChecked ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<PhotoEntry> CREATOR = new Creator<PhotoEntry>() {
        @Override
        public PhotoEntry createFromParcel(Parcel in) {
            return new PhotoEntry(in);
        }

        @Override
        public PhotoEntry[] newArray(int size) {
            return new PhotoEntry[size];
        }
    };

    public void toggle() {
        isChecked = !isChecked;
    }

    public int getBucketId() {
        return bucketId;
    }

    public void setBucketId(int bucketId) {
        this.bucketId = bucketId;
    }

    public int getImageId() {
        return imageId;
    }

    public void setImageId(int imageId) {
        this.imageId = imageId;
    }

    public long getDateTaken() {
        return dateTaken;
    }

    public void setDateTaken(long dateTaken) {
        this.dateTaken = dateTaken;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }
}
